package zheezes.protocol.impl.gd.bean;

import java.math.BigDecimal;

import zheezes.protocol.impl.gd.converter.MeterValueConverter;
import zheezes.util.ArrayUtil;


public class SimpleMeterData extends AbstractMeterData {
	private BigDecimal value = new BigDecimal("0.00");

	public SimpleMeterData() {
	}

	public SimpleMeterData(byte[] buf) {
		setBytes(buf);
	}

	public int size() {
		return 4;
	}
	
	@Override
	public int getBytes(byte[] buf, int offset) {
		return 0;
	}

	@Override
	public int setBytes(byte[] buf, int offset, int max) {
		 byte[] tmp = new byte[size()];
		 System.arraycopy(buf, offset, tmp, 0, tmp.length);
		 ArrayUtil.reverse(tmp);
		 value = MeterValueConverter.btov(tmp);

		return 4;
	}

	public BigDecimal getValue() {
		return value;
	}
}
